
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[DimSubMerchant]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
 drop table [dbo].[DimSubMerchant]

GO

CREATE TABLE [dbo].[DimSubMerchant] (
	[SubMerchantKey] [int] IDENTITY (1, 1) NOT FOR REPLICATION NOT NULL,
	[SubMerchantIdentifier] [varchar] (30) NOT NULL,
	[SubMerchantFullName] [nvarchar] (150) NOT NULL,
	[SubMerchantType] [nvarchar] (50) NOT NULL,
	[StreetNumber] [int] NOT NULL,
	[StreetNumberSuffix] [varchar] (50) NOT NULL,	
	[StreetName] [nvarchar] (100) NOT NULL,
	[StreetType] [nvarchar] (100) NOT NULL,	
	[StreetDirection] [nvarchar] (100) NOT NULL,
	[AddressType] [nvarchar] (100) NOT NULL,
	[AddressTypeIdentifier] [nvarchar] (100) NOT NULL,
	[MinorMunicipality] [nvarchar] (100) NOT NULL,
	[MajorMunicipality] [nvarchar] (100) NOT NULL,
	[GoverningDistrict] [nvarchar] (100) NOT NULL,	
	[PostalCode] [nvarchar] (20) NOT NULL,
	[Country] [nvarchar] (100) NOT NULL,
	[GeoLatitude] [varchar] (20) NOT NULL,
	[GeoLongitude] [varchar] (20) NOT NULL,
	[GeocodingSpatial] [geography] NOT NULL,

	CONSTRAINT [PK_SubMerchant] PRIMARY KEY CLUSTERED (
		   [SubMerchantKey])

)

GO

grant references, select, insert, delete, update on [dbo].[DimSubMerchant] to [db_datawriter]

GO

grant select on [dbo].[DimSubMerchant] to [public]

GO

